﻿using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeGenerator.Console
{
    class Program
    {
        private static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        private static CodeGeneratorCore codeGeneratorCore;
        static void Main(string[] args)
        {
            Initialize();
            log.Info("Application Start...");
            System.Console.WriteLine("Welcome to SE2 Code Generator...");
            codeGeneratorCore = new CodeGeneratorCore();
            codeGeneratorCore.Process();
            System.Console.WriteLine("Good bye...");
            System.Console.ReadKey();
            log.Info("Application End...");
        }

        private static void Initialize()
        {
            log4net.Config.XmlConfigurator.Configure();
            AppDomain currentDomain = AppDomain.CurrentDomain;
            currentDomain.UnhandledException += currentDomain_UnhandledException;
        }

        static void currentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var exception = e.ExceptionObject as Exception;
            
            log.Error(exception.Message, exception);
            System.Console.ReadKey();
        }
    }
}
